home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_shs_btladder.cog < prev    next >
Text File  |  1999-11-15  |  10KB  |  423 lines

  1. # Jones 3D Cog Script
  2. #
  3. # shs_BTladder.cog
  4. #
  5. # Make four ladders in the bell tower lower or raise
  6. #
  7. # [RKD, JWC]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10. # ================================================================================
  11.  
  12. symbols
  13.  
  14. message        activated
  15. message        timer
  16. message        startup
  17. message        damaged
  18.  
  19. keyframe    in_pull=in_pull_lever_down.key            local
  20. keyframe    lever_down=gen_lever.key                local
  21. keyframe    in_rtarmup=0in_armsout_1_1.key            local
  22. keyframe    in_thinking=0in_thinking_4_4.key        local
  23. keyframe    in_handsONhips=0in_stand4.key       local
  24. keyframe    in_sideTOhips=0in_stand1_bd_4.key   local
  25. keyframe    in_hipsTOside=0in_stand4_bd_1.key   local
  26.  
  27.  
  28.  
  29. sound        leverpull=nub_lever_pull_c.wav            local
  30. sound        leverback=nub_lever_reset_c.wav            local
  31. sound        in_readbell=Ss04j01a.wav                local
  32. sound        in_readbell2=Ss04j01b.wav                local
  33. sound        laddermove=shs_ladder_creak_c.wav        local
  34. sound        ladderstop=shs_ladderroll_stop.wav        local
  35. sound        bellhit=shs_bell_dull.wav                local
  36. sound        in_mustbediff=Inxj095.wav                local    # Must be a different way
  37. sound        in_bells=Ss04j04.wav                    local
  38.  
  39. surface        climbable0            nolink    
  40. surface        climbable1            nolink
  41. surface        climbable2            nolink
  42. surface        climbable3            nolink
  43. surface        climbable4            nolink
  44. surface        climbable5            nolink
  45. surface        climbable6            nolink
  46. surface        climbable7            nolink
  47.  
  48. thing        player                local
  49. thing        indy             
  50. thing        bell                    mask=0x408
  51.  
  52. thing        ladder0                linkid=1
  53. thing        ladder1                linkid=1
  54. thing        ladder2                linkid=1
  55. thing        ladder3                linkid=1
  56.  
  57. thing       lever
  58. thing        cam1
  59.  
  60. thing        c1_t1
  61. thing        c1_t2
  62. thing        c1_t3
  63. thing        in_mk1
  64. thing        in_mk2
  65. thing        in_mk3
  66.  
  67. vector        indyVector            local
  68.  
  69. flex        dotProduct            local
  70. flex        rightDot            local
  71.  
  72. int            open=0        local
  73. int            locked=0    local
  74. int            curCam        local
  75. int            readbell=0    local
  76. int            calls=0        local     # prevent overflow
  77.     
  78. int            comment=0    local
  79. int            index        local
  80. int            canReadBell    local
  81. int         in_track0    local
  82. int            in_track1     local
  83. int            in_rotrate=0local
  84.  
  85. #SUBROUTINES
  86. flex        openladders            local
  87. flex         closeladders        local
  88. flex        returncontrol        local
  89.  
  90.  
  91.  
  92. end
  93.  
  94. # ================================================================================
  95. code
  96.  
  97. startup:
  98.     
  99.     # Prep
  100.     sleep(.01);
  101.     player = GetLocalPlayerThing();
  102.     
  103.  
  104.     return;
  105. # ................................................................................
  106.  
  107. activated:
  108.     
  109.        # Indy pulls lever
  110.     if (GetSenderRef() == lever)
  111.     {
  112.         curCam = GetCurrentCamera();
  113.         if (locked) return;
  114.         locked = 1;
  115.     
  116.         call leverpull;
  117.          
  118.         if (open == 0) 
  119.         {
  120.             call openladders;
  121.                
  122.             if (readbell == 0)
  123.             {     
  124.                 # Indy reads bell just once
  125.                 call readbell;
  126.                 readbell=1;
  127.             }
  128.         }
  129.         else
  130.         {
  131.             call closeladders;
  132.         }
  133.       
  134.         call returncontrol;
  135.     }
  136.     
  137.     # Indy activates bell
  138.     
  139.     if ((GetSenderRef() == bell) && (calls == 0))
  140.     {
  141.         #if (read != 1) return;
  142.  
  143.         # Compute vector from bell to Indy
  144.         indyVector = VectorNorm(VectorSub(GetThingPos(bell), GetThingPos(player)));
  145.  
  146.         # Check to see where Indy is standing relative to the statue
  147.         dotProduct = VectorDot(GetThingLVec(bell), indyVector);
  148.         rightDot = VectorDot(GetThingRVec(bell), indyVector);
  149.  
  150.         //DEBUGFLEX(dotProduct, "Dot product:");
  151.         //DEBUGFLEX(rightDot, "Right dot:");
  152.  
  153.         canReadBell = 0;
  154.  
  155.         if ((dotProduct <= 0.256137) && (dotProduct >= -0.6680111) && (rightDot < 0))
  156.         {
  157.             // Indy is in front of one inscription.
  158.             canReadBell = 1;
  159.         }
  160.         else
  161.         {
  162.             if ((dotProduct <= 0.708848) && (dotProduct >= -0.227464) && (rightDot > 0))
  163.             {
  164.                 // Indy is in front of the other inscription.
  165.                 canReadBell = 1;
  166.             }
  167.         }
  168.  
  169.         // If Indy's not in a valid spot, bail
  170.         if (!canReadBell)
  171.             return;
  172.  
  173.         calls = 1;
  174.         SetActorFlags(player, 0x200000); # paralyze him
  175.         StartCutscene(0);
  176.         StopThing(player);
  177.         CopyPlayerHolsters(player, indy); # make sure our actor has matching props
  178.         CopyOrientAndPos(player, indy);
  179.                 
  180.         SetExtCamOffset('0.15 -0.1 0.15');
  181.         #SetExtCamLookOffset('0.0 0.1 0.0'); # this verb is no good
  182.         
  183.         SetThingFlags(player, 0x80000);
  184.         ClearThingFlags(indy, 0x80000);
  185.         
  186.         if (readbell != 1)
  187.         {
  188.             
  189.             # "There's some writing..."
  190.             PlayVoice(player, in_readbell, 1.0, 1);
  191.             
  192.             # "Ring for the Master."
  193.             PlayVoice(player, in_readbell2, 1.0, 0);
  194.             
  195.             # Indy gestures
  196.             PlayKey(indy, in_rtarmup, 4, 0x12, 1);
  197.             sleep(.5);
  198.  
  199.             in_track0 = PlayKey(indy, in_handsONhips, 2, 0x00, 0);
  200.             PlayKey(indy, in_sideTOhips, 4, 0x12, 1);
  201.             in_track1 = PlayKey(indy, in_thinking, 4, 0x12, 0);
  202.             # "Bells are rung..."
  203.             PlayVoice(indy, in_bells, 1.0, 1);
  204.                    
  205.             StopKey(indy, in_track0, 0.5);
  206.             StopKey(indy, in_track1, 0.5);
  207.             sleep(1);
  208.         }
  209.         else
  210.         {
  211.             # "Ring for the Master."
  212.             PlayVoice(player, in_readbell2, 1.0, 1);
  213.         }
  214.         
  215.         readbell=1;
  216.         calls=0;
  217.                 
  218.         # Reset the camera
  219.         RestoreExtCam();
  220.  
  221.         # Enable player control
  222.         ReleaseThing(player);
  223.         ClearThingFlags(player, 0x80000);
  224.         SetThingFlags(indy, 0x80000);
  225.         EndCutscene();
  226.         ClearActorFlags(player, 0x200000);
  227.     }
  228.     return;
  229.  
  230. # ................................................................................
  231.  
  232. damaged:
  233.      
  234.     if (GetSenderRef() != bell) return;
  235.       
  236.     if (GetCurWeapon(player) == 1)
  237.     {
  238.         PlaySoundThing(bellhit, bell, 1.0, 3, 8, 0);
  239.     }
  240.     else
  241.     {
  242.         Sleep(.2);
  243.         PlaySoundThing(bellhit, bell, 1.0, 3, 8, 0);
  244.     }
  245.     
  246.     # only if indy has read bell
  247.     if (readbell == 1)
  248.     {
  249.         # just once...
  250.         if (comment== 1) return; 
  251.         sleep(1);
  252.         PlayVoice(player, in_mustbediff, 1.0, 0);
  253.         comment=1;
  254.     }
  255.     return;
  256.  
  257. # ................................................................................
  258.  
  259.  
  260. leverpull:    
  261.     
  262.  
  263.     # Disable player...
  264.     TeleportThing(indy, in_mk3);
  265.     SetActorFlags(player, 0x200000); # paralyze him
  266.     StartCutscene(1);
  267.     StopThing(player); # right now
  268.     PlayMode(player, 1, 0); # get him into a nice stand
  269.     DeselectWeapon(player); # stow any weapon or lighter
  270.     CopyPlayerHolsters(player, indy); # make sure our actor has matching props
  271.     Sleep(0.5); # give him some time to do his stuff
  272.     
  273.         
  274.  
  275.     # Switch actor indy for player...
  276.     SetThingFlags(player, 0x80000); # hide him
  277.     ClearThingFlags(indy, 0x80000); # reveal our actor
  278.     
  279.     # Prep camera & cut...
  280.     SetCameraLookInterp(2, 0); # no pan & tilt
  281.     SetCameraPosInterp(2, 0); # no dolly
  282.     SetCameraFocus(2, cam1);
  283.     SetCameraSecondaryFocus(2, c1_t1);
  284.     Sleep(0.01);
  285.     SetCurrentCamera(2);
  286.     SetCameraFOV(68, 0, 0.0);
  287.    
  288.  
  289.     PlayKey(lever, lever_down, 4, 0x12, 0);
  290.     PlayKey(indy, in_pull, 4, 0x12, 0);
  291.     Sleep(1.2);
  292.     PlaySoundLocal(leverpull, 1.0, 0, 0x0000, 0);
  293.     Sleep(1.4);
  294.     PlaySoundLocal(leverback, 1.0, 0, 0x0000, 0);
  295.     Sleep(0.3);
  296.  
  297.     # Indy turns to ladder
  298.     in_rotRate = GetThingMaxRotVel(player);     # remember Indy rate
  299.     SetThingMaxRotVel(indy, 100.0);
  300.     AISetLookThing(indy, c1_t2);
  301.      
  302.     # Show ladder opening
  303.     SetCameraLookInterp(2, 1); #  pan & tilt
  304.     SetCameraInterpSpeed(2, 2.0); #  pan & tilt
  305.     Sleep(0.01);
  306.     SetCameraSecondaryFocus(2, c1_t2);
  307.     sleep(1.0);
  308.  
  309.  
  310. return;
  311.  
  312. # ................................................................................
  313.  
  314. openladders:        
  315.     
  316.   
  317.     # make adjoins no player move and climbable
  318.         
  319.     for (index = 0; index < 8; index = index + 1)
  320.     {
  321.         ClearAdjoinFlags(climbable0[index], 0x2);
  322.         SetSurfaceFlags(climbable0[index], 0x2000);
  323.     }
  324.     
  325.     Rotate(ladder0, -90, 0, 1.5);
  326.     Rotate(ladder1, -90, 2, 1.5);
  327.     Rotate(ladder2, -90, 0, 1.5);
  328.     Rotate(ladder3, -90, 2, 1.5);    
  329.     
  330.     PlaySoundLocal(laddermove, 1.0, 0, 0x0000, 0);
  331.     WaitForStop(ladder3);
  332.     PlaySoundLocal(ladderstop, 1.0, 0, 0x0000, 0);
  333.     
  334.     sleep(.5); #beat
  335.     open=1;
  336.  
  337.     return;
  338.     
  339. # ................................................................................
  340.  
  341. closeladders:
  342.         
  343.     //Close all ladders at once
  344.     
  345.     Rotate(ladder0, 90, 0, 1.5);
  346.     Rotate(ladder1, 90, 2, 1.5);
  347.     Rotate(ladder2, 90, 0, 1.5);
  348.     Rotate(ladder3, 90, 2, 1.5);
  349.     
  350.     PlaySoundLocal(laddermove, 1.0, 0, 0x0000, 0);
  351.     WaitForStop(ladder3);
  352.     PlaySoundLocal(ladderstop, 1.0, 0, 0x0000, 0);
  353.     
  354.     sleep(.5); #beat
  355.     open = 0;
  356.     return;
  357.  
  358. # ................................................................................
  359.  
  360. readbell:
  361.      
  362.     # Indy moves into frame
  363.  
  364.     AISetMoveSpeed(indy, 1.0);
  365.     AISetLookThing(indy, in_mk2);
  366.     AISetMoveThing(indy, in_mk1, 0);
  367.     
  368.     
  369.     # move camera to look at bell
  370.     SetCameraLookInterp(2, 1); #  pan & tilt
  371.     SetCameraInterpSpeed(2, 2.0); #  pan & tilt
  372.     Sleep(0.01);
  373.     SetCameraSecondaryFocus(2, c1_t3);
  374.     SetCameraFOV(70, 1, 2.0);
  375.     sleep(2.0);
  376.     
  377.     AiWaitForStop(indy);
  378.     
  379.     # "There's some writing..." 
  380.     PlayVoice(indy, in_readbell, 1.0, 1);
  381.     
  382.     #"Ring for the Master."
  383.     PlayVoice(indy, in_readbell2, 1.0, 0);
  384.  
  385.     # Indy gestures
  386.     PlayKey(indy, in_rtarmup, 4, 0x12, 1);
  387.     sleep(.5);
  388.     in_track0 = PlayKey(indy, in_handsONhips, 2, 0x00, 0);
  389.     PlayKey(indy, in_sideTOhips, 4, 0x12, 1);
  390.     in_track1 = PlayKey(indy, in_thinking, 4, 0x12, 0);
  391.     
  392.     # "Bells are rung..."
  393.     PlayVoice(indy, in_bells, 1.0, 1);
  394.  
  395.     StopKey(indy, in_track0, 0.5);
  396.     StopKey(indy, in_track1, 0.5);
  397.     sleep(1);
  398.  
  399.     return;
  400. # ................................................................................
  401.  
  402. returncontrol:
  403.  
  404.     
  405.        locked =0;    //allow activation of switch again
  406.  
  407.     # Restore player control...
  408.     CopyOrientAndPos(indy, player); # pop player to actor spot
  409.     SetThingFlags(indy, 0x80000); # hide actor    
  410.     ClearThingFlags(player, 0x80000); # player visible
  411.     SetThingMaxRotVel(indy, in_rotRate);
  412.     SetCameraPosition(1, GetThingPos(cam1));    # prep for camera to swing back
  413.     SetCurrentCamera(curCam);
  414.     ResetCameraFOV(0, 0.0);
  415.     
  416.     ClearActorFlags(player, 0x200000); # player in control
  417.     EndCutscene();
  418.     return;
  419.  
  420.  
  421. end
  422.  
  423.